// userPackage/pages/register/register.js
import {ajaxFun} from "../../../utils/ajax"
Page({

 data:{
  username:"",
  password:""
 },
 registerFun(){
  let reg=/^1[3|5|6|7|8|9]\d{9}$/;
  console.log(reg.test(this.data.username));
   if(!reg.test(this.data.username)){//如果手机号不正确
     wx.showToast({
       title: '手机号错误',
       icon:"none"
     })
     return false;
   }

     this.submit()
 },
async submit(){
  let  result=await ajaxFun("/user/register","post",{
    "loginName": this.data.username,
    "password": this.data.password
  })
  if(result.resultCode===200){
    wx.showToast({
      title: '注册成功',
      icon:"none"
    })
     setTimeout(()=>{
      wx.reLaunch({
        url: '/userPackage/pages/login/login',
      })
     },1000)
  }
}
})